﻿using System.Collections.Generic;
using System.Linq;
using GuRenFang.Service.Entity;
using GuRenFang.Service.IDa;

namespace GuRenFang.Da
{
   public class ActivitiesRepository:RepositoryBase<Activities>,IActivitiesRepository
    {
       public ActivitiesRepository(IDatabaseFactory databaseFactory)
            : base(databaseFactory)
         {

         }

     
       public IEnumerable<Activities> GetItemsByPages(int pageIndex, int pageSize, string orderFiled, out int totalRecord)
       {
           var startRecord = pageSize * (pageIndex - 1);
           totalRecord = DataContext.Activities.Count();
           return this.DataContext.Activities.OrderByDescending(n => n.CreatedTime).Skip(startRecord).Take(pageSize);
       }
    }
}
